

##############################################################
#                                                            #
#   Get the includes and libraries needed by Queso	     #
#                                                            #
##############################################################

########################################################################################################
#                                       GSL part
########################################################################################################
# Defines:
# GSL_LIBRARIES
# GSL_INCLUDE_DIRS

#include dir
unset (GSL_INCLUDE_DIRS CACHE)

FIND_PATH(GSL_INCLUDE_DIRS gsl/gsl_version.h
 PATHS
  $ENV{GSL_DIR}/include/gsl
  $ENV{GSL_DIR}/include/
  $ENV{GSL_INC}/
  /usr/include/gsl/include
  /usr/include/gsl
  /usr/include/
)

if (NOT GSL_INCLUDE_DIRS)
  message (FATAL_ERROR " \n The include directory of the library gsl containing the file gsl_version.h has not been found. Directory checked:
			 from environment var. GSL_DIR: $ENV{GSL_DIR}/include/gsl
			 from environment var. GSL_DIR: $ENV{GSL_DIR}/include/
 			 from environment var. GSL_INC: $ENV{GSL_INC}/
                         /usr/include/gsl/include
                         /usr/include/gsl
                         /usr/include/ \n"
            )
endif (NOT GSL_INCLUDE_DIRS)


#-------------------  gsl lib ------------------------

find_library( GSL_LIB  gsl
 PATHS
  $ENV{GSL_DIR}/lib
  $ENV{GSL_LIB}/
  /usr/lib
)

if (NOT GSL_LIB)
  message (FATAL_ERROR " \n The include directory of the library gsl has not been found. Directory checked:
			 from environment var. GSL_DIR: $ENV{GSL_DIR}/lib
			 from environment var. GSL_DIR: $ENV{GSL_LIB}/include/
                         /usr/lib \n"
            )
endif (NOT GSL_LIB)

#-------------------  gslcblas lib ------------------------

find_library( GSLCBLAS_LIB  gslcblas
 PATHS
  $ENV{GSL_DIR}/lib
  $ENV{GSL_LIB}/
  /usr/lib
)

if (NOT GSLCBLAS_LIB)
  message (FATAL_ERROR " \n The include directory of the library gslcblas has not been found. Directory checked:
			 from environment var. GSL_DIR: $ENV{GSL_DIR}/lib
			 from environment var. GSL_DIR: $ENV{GSL_LIB}/include/
                         /usr/lib\n"
            )
endif (NOT GSLCBLAS_LIB)


SET (GSL_LIBRARIES ${GSL_LIB} ${GSLCBLAS_LIB})



MARK_AS_ADVANCED( GSL_INCLUDE_DIRS  GSL_LIB  GSLCBLAS_LIB )


########################################################################################################
#                                       BOOST part
########################################################################################################
# Defines:
# BOOST_LIBRARIES
# BOOST_INCLUDE_DIRS

FIND_PACKAGE( Boost COMPONENTS program_options REQUIRED )
FIND_PACKAGE( Boost COMPONENTS filesystem REQUIRED )
FIND_PACKAGE( Boost COMPONENTS system REQUIRED )

SET( BOOST_LIBRARIES   ${Boost_LIBRARIES}   )
SET( BOOST_INCLUDE_DIRS ${Boost_INCLUDE_DIR} )


unset (HDF5_INCLUDE_DIR CACHE)

FIND_PATH(HDF5_INCLUDE_DIR hdf5.h
 PATHS
  $ENV{HDF5_DIR}
  $ENV{HDF5_INC}
  /usr/include
  /usr/local/include
)

if (NOT HDF5_INCLUDE_DIR)
  message (FATAL_ERROR " \n\n The include directory of the library HDF5 containing the file hdf5.h has not been found. Directory checked:
			 from environment var. HDF5_DIR: $ENV{HDF5_DIR}/include
 			 from environment var. HDF5_INC: $ENV{HDF5_INC}/
                         /usr/include 
                         /usr/local/include \n"
            )

endif (NOT HDF5_INCLUDE_DIR)


find_library (HDF5_LIB hdf5 PATHS
              $ENV{HDF5_LIB}/lib
              $ENV{HDF5_LIB}/
              $ENV{SOAMS_LIBRARIES_PATH}/hdf5/lib
              /usr/lib/
              /usr/local/lib
)

if (NOT HDF5_LIB )
  message (FATAL_ERROR "\n\n The library libhdf5.a has not been found. Directory checked:
                         from environment var. HDF5_DIR: $ENV{HDF5_DIR}/lib
                         from environment var. HDF5_LIB: $ENV{HDF5_LIB}/
                         /usr/lib/
                         /usr/local/lib"
)

endif (NOT HDF5_LIB )


########################################################################################################
#                                          groovy  part    
########################################################################################################

unset (GRVY_INCLUDE_DIR CACHE)

FIND_PATH(GRVY_INCLUDE_DIR grvy.h
   PATHS
   $ENV{GRVY_DIR}/include
   $ENV{GRVY_INC}/
   /usr/include
   /usr/local/include
)

if (NOT GRVY_INCLUDE_DIR)
  message (FATAL_ERROR " \n\n The include directory of the library groovy containing the file hpct.h has not been found. Directory checked:
			 from environment var. GRVY_DIR: $ENV{GRVY_DIR}/include
 			 from environment var. GRVY_INC: $ENV{GRVY_INC}/
			 /usr/include 
                         /usr/local/include \n"
             )

endif (NOT GRVY_INCLUDE_DIR)

find_library (GRVY_LIB  grvy PATHS
   $ENV{GRVY_DIR}/lib
   $ENV{GRVY_LIB}/
   /usr/lib
   /usr/local/lib
)

if (NOT GRVY_LIB )
  message (FATAL_ERROR "\n\n The library libgrvy.a has not been found. Directory checked:
			 from environment var. GRVY_DIR: $ENV{GRVY_DIR}/lib
 			 from environment var. GRVY_LIB: $ENV{GRVY_LIB}/
                         /usr/lib 
                         /usr/local/lib\n"
             )

endif (NOT GRVY_LIB )

########################################################################################################
#                                     queso part
########################################################################################################

unset (QUESO_INCLUDE_DIR CACHE)

FIND_PATH(QUESO_INCLUDE_DIR uqEnvironment.h
 PATHS
  $ENV{QUESO_DIR}/include
  $ENV{QUESO_INC}/
  /usr/include
  /usr/local/include
)

if (NOT QUESO_INCLUDE_DIR)
  message (FATAL_ERROR " \n\n The include directory of the library QUESO containing the file uqEnvironment.h has not been found. Directory checked:
			 from environment var. QUESO_DIR: $ENV{QUESO_DIR}/include
 			 from environment var. QUESO_INC: $ENV{QUESO_INC}/
			 /usr/include 
                         /usr/local/include\n"
             )

endif (NOT QUESO_INCLUDE_DIR)

find_library (QUESO_LIB  queso PATHS
  $ENV{QUESO_DIR}/lib
  $ENV{QUESO_LIB}/
  /usr/lib
  /usr/local/lib
)

if (NOT QUESO_LIB )
  message (FATAL_ERROR "\n\n The library queso has not been found. Directory checked:
			 from environment var. QUESO_DIR: $ENV{QUESO_DIR}/lib
 			 from environment var. QUESO_LIB: $ENV{QUESO_LIB}/
                         /usr/include 
                         /usr/local/include\n"
             )
endif (NOT QUESO_LIB )

############
# mpi part #
############

find_package( MPI REQUIRED )

##############################################################

SET (ALL4QUESO_INCLUDE_DIRS ${BOOST_INCLUDE_DIRS} 
			    ${GSL_INCLUDE_DIRS} 
			    ${HDF5_INCLUDE_DIR}  
			    ${QUESO_INCLUDE_DIR} 
			    ${GRVY_INCLUDE_DIR}  
			    ${MPI_INCLUDE_PATH} 
			    ${CMAKE_CURRENT_SOURCE_DIR}/src/  
			    ${CMAKE_CURRENT_SOURCE_DIR}/src/ANN )
SET (ALL4QUESO_LIBRARIES    ${BOOST_LIBRARIES}    
			    ${GSL_LIBRARIES} 
			    ${HDF5_LIB}  
			    ${QUESO_LIB}         
			    ${GRVY_LIB}          
			    ${MPI_LIBRARIES}   )





